(function (Cofe, Spine, $) {

    var Models = Cofe.Models;

    var extractFileName = function (path) {
        var idx = path.lastIndexOf('/');
        if (idx != -1)
            return path.substring(idx + 1, path.length);
        return path;
    };

    Models.Entry = {
        extended: function () {
            this.include({
                initCommonProps: function (data) {
                    this.id = data.id;
                    this.label = extractFileName(data.path);
                    if (this.label == "")
                        this.label = data.path;
                    this.path = data.path;
                    this.basetype = data.basetype;
                    this.time = new Date(data.time);

                    this.links = {}
                    for (var i = 0, il = data.links.length; i < il; i++) {
                        var curLink = data.links[i];
                        var idx = curLink.rel[0].toLowerCase() + curLink.rel.substring(1, curLink.rel.length);
                        this.links[idx] = Cofe.Link.init(curLink.mediatype, curLink.rel, curLink.uri);

                        if (idx == "typeInfo")
                            this.icon = curLink.uri + "?rel=icon&size=small";
                    }

                }
            });
            //console.log("extended");
        },
        included: function () {
            //adding additional methods in extended
            //console.log("included");
        }
    };


})(Cofe, Spine, Spine.$);